const http = require('http');
const server = http.createServer((request,response) =>{
    // console.log('there is a request');
    // response.end('a response from server');
    console.log(request)
    const {url,method} = request
    if(url==='/' && method ==="GET"){
        response.setHeader('Content-Type', 'text/html');
        response.end('你是一个拖延症')
    }else if(url ==="/user" && method ==="GET"){
        response.writeHead(200, { 'Content-Type': 'application/json' });
        response.end(JSON.stringify([{name:'tom',age:20}]));
    }
    
})
server.listen(3000);